<!DOCTYPE html>
<html class="ui-page-login">

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>绑定门店</title>
		<link href="css/mui.min.css" rel="stylesheet" />
		<link href="css/style.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="css/mui.picker.min.css">
		<link href="css/reg_style.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="css/common.css"/>
		<style>
			.shop_postion{
				display: block;
				text-align: left;
				width: 72%;
				float: right;
				padding: 10px 0;
				font-size: 0.14rem;			
				
			}
			.c808080 {
				color: #ccc;
			}
			.head1 em{
				float: left;
				width: 0.27rem;
				height: 0.36rem;
			}
			.head1 .img1 {
				float: left;
				width: 0.15rem;
				height: 0.15rem;
				margin-top: 0.1rem;
				margin-left: 0.07rem;
			}
			.mui-poppicker-header .mui-btn{
				font-size: 0.15rem;
				background: none;
			    border: none;
			    color: #4198ff;
			}
		</style>

	</head>
	<style type="text/css">
		header em{
			color: #4198FF;
		}
	</style>
	<body>
		<header class="mui-bar mui-bar-nav head1">
			<em class="mui-action-back"><img class="img1" src="img/fanhui.png" alt="" /></em>
		</header>
		<div class="mui-content">
			<div class="mui-content-padded content-box">
				<h3 class="title-ver">申请加入门店</h3>
				<form id='login-form' class="mui-input-group">
					<div class="mui-input-row char4">
						<label style="color: #4D4D4D;">门店ID</label>
						<input onkeyup="user_bind_position();" id='shop_id' maxlength="4" pattern="\d*" type="number" placeholder="请输入您的门店ID">
					</div>

					<div class="mui-input-row char4">
						<label style="color: #4D4D4D;">职务</label>
						<span oninput="user_select_position();" id='shop_postion' class="shop_postion c808080">请选择您的门店职务</span>
						<input id='shop_postion_id' type="hidden" value="0">
					</div>

				</form>

				<button onclick="user_bind();" disabled="disabled" id='btn_login' class="mui-btn mui-btn-block mui-btn-primary" style="width: 110%;margin-left: -5%;">确定</button>
				<div class="link-area register">
					<a id='register' href="javascript:user_bind_demo();">申请加入DEMO体验店</a>
				</div>
			</div>
			<div class="mui-content-padded oauth-area">

			</div>
		</div>

		<script src="js/mui.min.js"></script>
		<script src="js/mui.enterfocus.js"></script>
		<script src="js/app.js"></script>
		<script src="js/jquery.js"></script>
		<script type="text/javascript" src="js/mui.picker.min.js"></script>
		<script type="text/javascript" src="js/jsencrypt.js"></script>
		<script src="js/md5.js"></script>
		<script src="js/crypto-js.js"></script>
		<script type="text/javascript" src="js/common.js"></script>
		<script>

			var picker = new mui.PopPicker();

			mui.ready(function() {

			});

			var bind_position_arr = {};
			var position_json = [];

			//选择职务
			function user_select_position() {
				if(Object.keys(bind_position_arr) < 1) {
					return false;
				}

				mui.each(bind_position_arr, function(index, item) {
					var xjson = {};
					xjson.value = bind_position_arr[index].id;
					xjson.text = bind_position_arr[index].name;
					position_json[index] = xjson;

				});
				//console.log(position_json);
				picker.setData(position_json);

				picker.show(function(SelectedItem) {
					$("#shop_postion").removeClass("c808080");
					
					mui("#shop_postion")[0].innerHTML = SelectedItem[0].text;
					mui("#shop_postion_id")[0].value = SelectedItem[0].value;

					var x = mui("#shop_postion_id")[0].value;

					if(parseInt(x) > 0) {
						document.getElementById("btn_login").disabled = false;
						btn_login_se('jianbian3_shengse',"#btn_login");
					} else {
						document.getElementById("btn_login").disabled = true;
						btn_login_se('jianbian1_qianse',"#btn_login");
					}
				})

			}

			//注册时获取职务列表
			function user_bind_position() {
				var shop_id = mui("#shop_id")[0].value;
				if(shop_id.length == 0) {
					return false;
				}


				$("#shop_postion").addClass("c808080");
				//存储到loaclStage   

				var sbx = {};
				sbx.id = storage["register_phone"];
				sbx.shop_id = shop_id;
				sbx.auth_token = storage["auth_token"];

				login_encrypt_md5(sbx);
				console.log(sbx);
				ajax_submit_before(url_host + 'user/bind/position', 'bind_position');

			}

			//开始绑定门店
			function user_bind() {

				var sbx = {};
				sbx.id = storage["register_phone"];
				sbx.shop_id = mui("#shop_id")[0].value; //店铺ID
				sbx.position_id = mui("#shop_postion_id")[0].value;; //职务ID
				sbx.auth_token = storage["auth_token"];

				login_encrypt_md5(sbx);
				console.log(sbx);
				ajax_submit_before(url_host + 'user/bind', 'user_bind');

			}

			//申请加入体验店
			function user_bind_demo() {

				var sbx = {};
				sbx.id = storage["register_phone"];

				login_encrypt_md5(sbx);
				//console.log(sbx);
				ajax_submit_before(url_host + 'user/bind/demo', 'user_bind_demo');

			}
		</script>
	</body>

</html>